<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>toggle(fn,fn)</title>
<meta name="keywords" content="jQuery 1.2 API Reference,Visual jQuery 1.2,jQuery doc,jQuery API,jQuery,jQuery 1.2 API 参考文档中文版,中文版" />
<meta name="description" content="jQuery 1.2 API 文档中文版，提供最新版 jQuery 开发帮助。" />
<link rel="stylesheet" type="text/css" href="../../style/jqueryapi.css" />
<script type="text/javascript" src="../../style/lib/jquery126.js"></script>
 </script>
<script type="text/javascript" src="../../style/jqueryapi.js"></script>
<link rel="shortcut icon" href="../../style/img/favicon.ico" />
</head>
<body>
<div id="topnav">
		<a href="http://www.jQuery.com/" title="jQuery官网" target="_blank" class="topnav">jQuery官网</a>
	<span class="topnav">|</span>
	<a href="http://jquery.org.cn/" title="jQuery中文网站" target="_blank" class="topnav">jQuery中文网站</a>
	<span class="topnav">|</span>
	<a href="http://www.cn-cuckoo.com/" title="1.1版译者" target="_blank" class="topnav">为之漫笔</a>
	<span class="topnav">|</span>
	<a href="http://shawphy.com/" title="1.2版翻译整理者" target="_blank" class="topnav">Shawphy</a>
    <span class="topnav">|</span>
	<a href="http://www.51toria.cn" title="CHM文档制作者:一揪" target="_blank" class="topnav">CHM文档制作者</a> 
	<span class="topnav">|</span>
	<a href="http://dl.getdropbox.com/u/81097/jQueryAPI_CHM.CHM" title="" target="_blank" class="topnav">CHM最新版本下载</a> 
</div>
<hr style="color:#595959;" />

<div class="content">
				<h1>toggle(fn,fn)</h1>
				<div class="desc"><div>每次点击后依次调用函数。</div> <div class="longdesc"><p>如果点击了一个匹配的元素，则触发指定的第一个函数，当再次点击同一元素时，则触发指定的第二个函数，如果有更多函数，则再次触发，直到最后一个。随后的每次点击都重复对这几个函数的轮番调用。</p><p>可以使用unbind("click")来删除。</p></div></div><hr />
				<div class="desc"><div>Toggle among two or more function calls every other click.</div> <div class="longdesc"><p>Whenever a matched element is clicked, the first specified function is fired, when clicked again, the second is fired, and so on. All subsequent clicks continue to rotate through the functions.</p><p>Use unbind("click") to remove.</p></div></div>
				<h2>返回值</h2>
				<p class="indent">jQuery</p>
				<h2>参数</h2>
				<p class="indent"><strong>fn </strong>(Function) : 第一数次点击时要执行的函数。</p>
				<p class="indent"><strong>fn2 </strong>(Function) : 第二数次点击时要执行的函数。</p>
				<p class="indent"><strong>fn3,fn4,... </strong>(Function) : 更多次点击时要执行的函数。</p>
				<h2>示例</h2>
				<p class="indent">
					对表格的切换一个类
				</p>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
					$("td").toggle(<br/>
&nbsp; function () {<br/>
&nbsp;&nbsp;&nbsp; $(this).addClass("selected");<br/>
&nbsp; },<br/>
&nbsp; function () {<br/>
&nbsp;&nbsp;&nbsp; $(this).removeClass("selected");<br/>
&nbsp; }<br/>
); 
				</div>
				<p class="indent">
					对列表的切换样式
				</p>
				<p class="indent"><strong>HTML 代码:</strong></p>
				<div class="code">
&nbsp;&nbsp;&lt;ul&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;Go&nbsp;to&nbsp;the&nbsp;store&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;Pick&nbsp;up&nbsp;dinner&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;Debug&nbsp;crash&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;Take&nbsp;a&nbsp;jog&lt;/li&gt;<br />
&nbsp;&nbsp;&lt;/ul&gt;
				</div>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
&nbsp;&nbsp;&nbsp;&nbsp;$("li").toggle(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(this).css({"list-style-type":"disc",&nbsp;"color":"blue"});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(this).css({"list-style-type":"disc",&nbsp;"color":"red"});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(this).css({"list-style-type":"",&nbsp;"color":""});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;);<br />
				</div>
			</div>
            
</body>
</html>
